package com.pla.persistence;

import java.util.ArrayList;
import java.util.List;

/**
 * DAO for the {@link Vine} entity. (see DAO pattern for more informations about
 * DAOs).
 * 
 * @author philipplang
 * 
 */
public class VineDao {

	private static List<Vine> vines;

	static {
		vines = new ArrayList<Vine>();

		// add some dummy data
		Vine vine1 = new Vine();
		vine1.setId(1);
		vine1.setName("Dos Puntos");
		vine1.setDescription("Bestellt auf vinos.de");
		vine1.setAge(2007);

		Vine vine2 = new Vine();
		vine2.setId(2);
		vine2.setName("Barolo irgendwas");
		vine2.setAge(2007);
		vine2.setRanking(3.5F);

		vines.add(vine1);
		vines.add(vine2);

	}

	public List<Vine> getOrderedVines() {
		return vines;
	}

	public Vine loadVine(long id) {
		for (Vine vine : vines) {
			if (vine.getId() == id) {
				return vine;
			}
		}
		return null;
	}
}
